﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace dzs.Web.supplierinfo
{
    public partial class Modify : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    int sid = (Convert.ToInt32(Request.Params["id"]));
                    ShowInfo(sid);
                }
            }
        }

        private void ShowInfo(int sid)
        {
            dzs.BLL.supplierinfo bll = new dzs.BLL.supplierinfo();
            dzs.Model.supplierinfo model = bll.GetModel(sid);
            //this.lblsid.Text = model.sid.ToString();
            this.txtsno.Text = model.sno;
            this.txtsname.Text = model.sname;
            this.txtsadd.Text = model.sadd;
            this.txtslink.Text = model.slink;
            this.txtsphone.Text = model.sphone;
            this.txtsfax.Text = model.sfax;
            this.txtsemail.Text = model.semail;
            this.txtpslink.Text = model.pslink;
            this.txtpsphone.Text = model.psphone;
            this.txtpsfax.Text = model.psfax;
            this.txtpsemail.Text = model.psemail;

        }

        public void btnSave_Click(object sender, EventArgs e)
        {

            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int sid = (Convert.ToInt32(Request.Params["id"]));
                string sno = this.txtsno.Text;
                string sname = this.txtsname.Text;
                string sadd = this.txtsadd.Text;
                string slink = this.txtslink.Text;
                string sphone = this.txtsphone.Text;
                string sfax = this.txtsfax.Text;
                string semail = this.txtsemail.Text;
                string pslink = this.txtpslink.Text;
                string psphone = this.txtpsphone.Text;
                string psfax = this.txtpsfax.Text;
                string psemail = this.txtpsemail.Text;


                dzs.Model.supplierinfo model = new dzs.Model.supplierinfo();
                model.sid = sid;
                model.sno = sno;
                model.sname = sname;
                model.sadd = sadd;
                model.slink = slink;
                model.sphone = sphone;
                model.sfax = sfax;
                model.semail = semail;
                model.pslink = pslink;
                model.psphone = psphone;
                model.psfax = psfax;
                model.psemail = psemail;

                dzs.BLL.supplierinfo bll = new dzs.BLL.supplierinfo();
                bll.Update(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "List.aspx");
            }

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
